//
//  CubeSettingPlugin.m
//  Module
//
//  Created by Fanty on 14-1-3.
//  Copyright (c) 2014年 Fanty. All rights reserved.
//

#import "CubeSettingPlugin.h"
#import <chameleon-ios-sdk/ZillaUrlScheme.h>
#import <chameleon-ios-sdk/ZillaAccessData.h>
#import "DataCenter+Cube.h"

@implementation CubeSettingPlugin

-(void)getAppInfo:(CDVInvokedUrlCommand*)command{
    NSString* callbackId=command.callbackId;
    
    ZillaUrlScheme* urlScheme=[[ZillaUrlScheme alloc] init];
    urlScheme.zillaAccessData=[ZillaAccessData activeSession];

    NSMutableString* json=[[NSMutableString alloc] initWithCapacity:5];
    [json appendString:@"{"];
    [json appendFormat:@"\"%@\":\"%@\",",@"appId",[[NSBundle mainBundle] bundleIdentifier]];
    [json appendFormat:@"\"%@\":\"%@\",",@"appKey",urlScheme.zillaAccessData.appKey];
    [json appendFormat:@"\"%@\":\"%@\",",@"sessionKey",urlScheme.zillaAccessData.appToken];
    [json appendFormat:@"\"%@\":\"%@\",",@"loginUrl",[[urlScheme loginURL] absoluteString]];
    [json appendFormat:@"\"%@\":\"%@\"",@"logoutUrl",[[urlScheme logoutURL] absoluteString]];

    [json appendString:@"}"];


    CDVPluginResult*pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:json];
    
    [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
        
}


@end
